package com.yeyv.net.UsefulEntity;

/**
 * 返回结果 - Entity
 *
 * @type Entity
 * @author 夜雨
 * @do 返回结果
 */
public class Resp<T> {
    public int code;

    public String info;

    public String msg;

    public T result;

    public long useTime;

    public Resp(){

    }

    public Resp(int code,String msg,T result){
        this.code=code;
        this.msg=msg;
        this.result=result;
    }

    public Resp(int code,String msg,String info,T result){
        this.code=code;
        this.msg=msg;
        this.info=info;
        this.result=result;
    }

    public static <V> Resp<V> success(V result){
        Resp<V> resp = Constant.ResponseSuccess();
        resp.result=result;
        return resp;
    }

    public static <V> Resp<V> success(V result,long useTime){
        Resp<V> resp = Constant.ResponseSuccess();
        resp.result=result;
        resp.useTime=useTime;
        return resp;
    }

    public static <V> Resp<V> success(String msg,V result){
        Resp<V> resp = Constant.ResponseError();
        resp.msg=msg;
        resp.result=result;
        return resp;
    }

    public static <V> Resp<V> success(String msg, V result ,long useTime){
        Resp<V> resp = Constant.ResponseError();
        resp.msg=msg;
        resp.useTime=useTime;
        resp.result=result;
        return resp;
    }

    public static <V> Resp<V> success(String info,String msg, V result){
        Resp<V> resp = Constant.ResponseError();
        resp.msg=msg;
        resp.info=info;
        resp.result=result;
        return resp;
    }

    public static <V> Resp<V> success(String info,String msg, V result,long useTime){
        Resp<V> resp = Constant.ResponseError();
        resp.msg=msg;
        resp.info=info;
        resp.result=result;
        resp.useTime=useTime;
        return resp;
    }

    public static <V> Resp<V> error(V result){
        Resp<V> resp = Constant.ResponseError();
        resp.result=result;
        return resp;
    }

    public static <V> Resp<V> error(String msg,V result){
        Resp<V> resp = Constant.ResponseError();
        resp.msg=msg;
        resp.result=result;
        return resp;
    }

    public static <V> Resp<V> error(String info,String msg, V result){
        Resp<V> resp = Constant.ResponseError();
        resp.msg=msg;
        resp.info=info;
        resp.result=result;
        return resp;
    }

    public static <V> Resp<V> reject(V result){
        Resp<V> resp = Constant.ResponseAuthReject();
        resp.result=result;
        return resp;
    }
}
